package com.example.demo.order.web;

import com.example.demo.order.entity.Order;
import com.example.demo.order.service.OrderService;
import com.example.demo.utils.RespMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/order")
public class OrderController {


    @Autowired
    private OrderService orderService;

    /**
     * 查询所有订单
     * @return
     */
    @RequestMapping("/list")
    public RespMessage findList(Order order){
        List<Order> list = orderService.findList(order);
        return RespMessage.success("成功",list);
    }


    /**
     * 查询所有单个订单
     * @return
     */
    @RequestMapping("/get")
    public RespMessage findOne(String id){

        orderService.findOne(id);
        return RespMessage.success("成功");
    }

    /**
     * 删除单个订单
     * @return
     */
    @RequestMapping("/remove")
    public RespMessage remove(String id){

        orderService.remove(id);

        return RespMessage.success("成功");
    }

    /**
     * 添加订单
     * @return
     */
    @RequestMapping("/save")
    public RespMessage save(Order order){
        orderService.save(order);
        return RespMessage.success("成功");
    }

    /**
     * 修改订单
     * @return
     */
    @RequestMapping("/update")
    public RespMessage update(Order order){

        orderService.update(order);
        return RespMessage.success("成功");
    }

}
